<template>
  <view style="padding-top: 100rpx; padding-left: 20rpx; padding-right: 20rpx;">
    <view class="input-area">
      <text class="label">输入值：</text>
      <input type="text" v-model="title" class="common-box" />
    </view>
    <view class="callback-area" style="margin-top: 20rpx;">
      <text class="label">回传值：</text>
      <text class="common-box">{{ callbackValue }}</text>
    </view>
    <comA :intent="title"></comA>
    <comB @callBackFun="callBack"></comB>
  </view>
</template>

<script>
import comA from '../../components/compA.vue'
import comB from '../../components/compB.vue'
export default {
  components: { comA, comB },
  data() {
    return {
      title: '',
      callbackValue: ''
    }
  },
  methods: {
    callBack(msg) {
      console.log('父组件收到B的回传值：', msg);
      this.callbackValue = msg;
    }
  }
}
</script>

<style>
.input-area{
  display: flex;
  align-items: center;
  gap: 10rpx;
  margin-bottom: 30rpx;
}
.callback-area {
  display: flex;
  align-items: center;
  gap: 10rpx;
  margin-bottom: 50rpx;
}

.label {
  font-size: 28rpx;
  color: #333;
  white-space: nowrap; 
}

.common-box {
  flex: 1; 
  box-sizing: border-box;
  background-color: #ddd; 
  padding: 10rpx; 
  border-radius: 4rpx; 
  color: red; 
  display: block;
  font-size: 28rpx;
  border: none; 
}

.common-box:focus {
  background-color: #eee;
}
</style>